package com.tangshuai.video.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.tangshuai.video.po.VideoInfo;
import com.tangshuai.video.service.VideoInfoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author TANGSHUAI
 * @Date 2024-03-05 00:32
 **/
@Controller
public class IndexController {

    private Logger logger = LoggerFactory.getLogger(IndexController.class);

    @Autowired
    private VideoInfoService videoInfoService;

    /**
     * 分页查询视频信息
     * @param request
     * @return
     */
    @RequestMapping("/")
    public String selectAllVideoInfo(HttpServletRequest request, VideoInfo videoInfo) {
        String ipAddress = request.getRemoteAddr();
        logger.info("访问客户端IP地址: {}" ,ipAddress);
        IPage<VideoInfo> videoInfoIPage = videoInfoService.selectAllVideoInfo(1, 30,videoInfo);
        request.setAttribute("videoInfoIPage", videoInfoIPage);
        return "index";
    }
}
